{% extends "base.html.twig" %}

{% block content %}
    <h1>{{ content.title }}</h1>
    <p>{{ content.url }}</p>
    {{ content.text_editor|raw }}

    {% for block in content.blocks %}
        {% if block.type == 'editor' %}
            {{ block.text_editor|raw }}
        {% elseif block.type == 'text_block' %}
            <h2>
                {{ block.title }}
            </h2>
            {{ block.description|raw }}
        {% elseif block.type == 'media' %}
            {% for media in block.media_selection %}
                <img src="{{ media.thumbnails['sulu-260x'] }}" />
            {% endfor %}
        {% elseif block.type == 'block' %}
            {% for subblock in block.blocks %}
                {% if subblock.type == 'editor' %}
                    {{ subblock.text_editor|raw }}
                {% elseif subblock.type == 'media' %}
                    {% for media in subblock.media_selection %}
                        <img src="{{ media.thumbnails['sulu-260x'] }}" />
                    {% endfor %}
                {% endif %}
            {% endfor %}
        {% endif %}
    {% endfor %}

    <p>{{ content.number }}</p>
    <p>{{ content.phone }}</p>

    {% if content.location %}
        <p>
            {{ content.location.street }} {{ content.location.number }}<br />
            {{ content.location.code }} {{ content.location.town}}
        </p>
    {% endif %}

    <p>{{ content.tag_selection|join(', ') }}</p>
    <p>{{ content.single_select }}</p>
    <p>{{ content.select|join(', ') }}</p>
    <p>{{ content.checkbox }}</p>
    <p>{{ content.color }}</p>
    <p>{{ content.time }}</p>
    <p>{{ content.date }}</p>
    <p>{{ content.datetime  ? content.datetime.format('Y-m-d H:i') : '' }}</p>
    <p>{{ content.email }}</p>
    <p>{{ content.link }}</p>

    {% if content.single_page_selection %}
        {% set page = content.single_page_selection %}
        {% if page %}
            <a href="{{ sulu_content_path(page.url) }}">{{ page.title }}</a>
        {% endif %}
    {% endif %}

    <p>{{ content.page_selection|map(page => page.title)|join(', ') }}</p>
    <p>{{ content.teaser_selection|map(teaser => teaser.title)|join(', ') }}</p>
    <p>{{ content.smart_content|default([])|map(page => page.title)|join(', ') }}</p>
    <p>{{ content.single_snippet_selection ? content.single_snippet_selection.title : '' }}</p>
    <p>{{ content.snippet_selection|map(snippet => snippet.title)|join(', ') }}</p>
    <p>{{ content.category_selection|map(category => category.name)|join(', ') }}</p>

    <p>{{ content.single_category_selection ? content.single_category_selection.name : ''}}

    {% if content.single_media_selection %}
        <img src="{{ content.single_media_selection.thumbnails['sulu-260x'] }}" />
    {% endif %}

    {% for media in content.media_selection %}
        <img src="{{ media.thumbnails['sulu-260x'] }}" />
    {% endfor %}

    {% if content.single_account_selection %}
        <p>{{ content.single_account_selection.name }}</p>
    {% endif %}

    <p>{{ content.account_selection|map(account => account.name)|join(', ') }}</p>

    {% if content.single_contact_selection %}
        <p>{{ content.single_contact_selection.fullName }}</p>
    {% endif %}

    <p>{{ content.contact_selection|map(contact => contact.fullName)|join(', ') }}</p>

    <p>{{ content.contact_account_selection|map(contact => contact.name ?? contact.fullName)|join(', ') }}</p>
    <p>{{ content.text_area }}</p>

    {% if content.image_map %}
        {% include 'pages/includes/image_map.html.twig' with {image_map: content.image_map} only %}
    {% endif %}
{% endblock %}
